/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			pgcmdargs.h
  \date			Aug 2012
  \author		TNick

  \brief		Contains the definition for CmdArgs class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __PGCMDARGS_INC__
#define __PGCMDARGS_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<cpg/cpg.h>
#include	<control/cmdargs.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

struct	P2D;

namespace		PlugIns		{
class	PlugIn ;
}

namespace cpg	{

class	CpgDoc;
class	PgSpace;
class	IDrawFile;

/**
*	@brief	Structure that hosts the text input in a convenient form
*/
class CPGSHARED_EXPORT CmdArgs	: public BBlocks::CmdArgs			{
	BBM_TRACK( CmdArgs );

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:


	/**
	*	@brief	constructor;
	*/
	CmdArgs			(
			const QString &			s_cmd,
			const QString &			s_args
			);


	/**
	*	@brief	destructor;
	*/
	~CmdArgs			( void );



	/* ******************************************************************* */
	/** @name 	Ways to convert internal arguments to specific data        */
	/* ******************************************************************* */
	///@{


	/**
	*	@brief	get the space represented by first unnamed argument
	*
	*	The default provided in \b default_s is used if inst is NULL or
	*	there are no arguments. It is not used if the argument is numeric and
	*	out of bounds or is a name that is not found in the list of spaces.
	*	In these casses the method adds error messages to \b um.
	*/
	static PgSpace *	getSpace		(
			CmdArgs *					inst,
			CpgDoc *						doc,
			BBlocks::UserMsg &			um,
			PgSpace *					default_s = NULL
			);


	/**
	*	@brief	get x and y components
	*
	*	The method looks at named arguments ("X" and "Y"). If these are
	*	not to be found and there are two arguments at i, it attempts
	*	to convert the values to double.
	*
	*/
	DataSrc				getXY			( P2D & out, int i, BBlocks::UserMsg & um ) const;


	/**
	*	@brief	get the document represented by first argument
	*
	*	The argument is then extracted.
	*/
	CpgDoc *				getDocument		( BBlocks::UserMsg & um );


	/**
	*	@brief	get the document represented by the named argument "DOC"
	*
	*	The argument is then extracted.
	*/
	CpgDoc *				getNamedDoc		( BBlocks::UserMsg & um );


	/**
	*	@brief	get the space represented by the named argument "SPC"
	*
	*	The argument is then extracted.
	*/
	PgSpace *			getNamedSpace	(
			BBlocks::UserMsg &	um,
			CpgDoc *				doc,
			bool				b_use_crt = true
			);


	/**
	*	@brief	get the space represented by the named argument "SPC"
	*
	*	If the argument is found returns true, otherwise false.
	*	\b space is the space that was identified, or NULL
	*/
	bool				getNamedSpace	(
			BBlocks::UserMsg &	um,
			CpgDoc *				doc,
			PgSpace **			space
			);


	/**
	*	@brief	get the file fomat represented by first argument
	*
	*	The argument is then extracted.
	*/
	IDrawFile *			getFileFormat	( BBlocks::UserMsg & um );


	/**
	*	@brief	get the plug-in associated with first argument
	*
	*	The argument is then extracted.
	*
	*	The method recognises either an numeric argument (interpreted as an index
	*	in the list of plug-ins) or a string argument (interpreted as the
	*	file path and name of the file).
	*
	*	Depending on the condition (plug-in loaded or not, a file being
	*	associated or not with it) both the return value and \b s_file may
	*	or may not be set.
	*
	*	If \b b_plg_req is set to true and an string argument is provided, the
	*	method will throw an error if the plug-in can't be located.
	*/
	PlugIns::PlugIn * getPlugIn		(
			QString &					s_file,
			BBlocks::UserMsg &			um,
			bool						b_plg_req = false
			);


	///@}
	/* ******************************************************************* */


	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class CmdArgs	*/

/*  CLASS    =============================================================== */
//
//
//
//

}	//	namespace cpg

#endif // __PGCMDARGS_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
